<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>客户资料</title>
		  <#assign base=request.contextPath  />
		 <link rel="stylesheet" href="${base}/js/layui/css/layui.css?t=1534970980648" media="all">
		 <script type="text/javascript" src="${base}/js/zhang.js"></script>
		 <script src="${base}/js/layui/layui.js" charset="utf-8"></script>
         <script type="text/javascript" src="${base}/js/ztree/jquery-1.4.4.min.js"></script>
         <script src="${base}/js/jquery.min.js"></script>

		<style type="text/css">
		form{
		  padding:20px;
		}
		.layui-btn-radius{
        			border-radius: 5px;
        		}
		</style>
	</head>
	<body>
	<form class="layui-form" action="">
        <div class="layui-form-item">
            <div class="layui-inline">
                 <label class="layui-form-label"><a style="color:red">*</a>&nbsp;姓名</label>
                       <div class="layui-input-inline">
                            <input name="number" id="name" lay-verify="required" autocomplete="off" class="layui-input isNull" type="text">
                        </div>
                      </div>

                      <div class="layui-inline">
                           <label class="layui-form-label" ><a style="color:red">*</a>&nbsp;联系电话</label>
                              <div class="layui-input-inline">
                                     <input name="number" id="phone" lay-verify="required|phone|number"  autocomplete="off" class="layui-input isPhone" type="text">
                              </div>
                      </div>


                      <div class="layui-inline">
                           <label class="layui-form-label" ><a style="color:red">*</a>&nbsp;家庭住址</label>
                                  <div class="layui-input-inline">
                                         <input name="number" id="address" lay-verify="required"  autocomplete="off" class="layui-input isNull" type="text">
                                                </div>
                                  </div>

                       <div class="layui-inline">
                            <label class="layui-form-label"><a style="color:red">*</a>&nbsp;大概预产期</label>
                                   <div class="layui-input-inline">
                                         <input name="date" id="date" lay-verify="date" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input isNull" type="text">
                                   </div>
                       </div>

                        <div class="layui-inline">
                             <label class="layui-form-label" ><a style="color:red">*</a>&nbsp;竞争对手</label>
                                   <div class="layui-input-inline">
                                        <input name="number" id="competitor" lay-verify="required"  autocomplete="off" class="layui-input isNull" type="text">
                                   </div>
                         </div>
                         <div class="layui-inline">
                          <label class="layui-form-label"><a style="color:red">*</a>&nbsp;预算</label>
                          <div class="layui-input-inline">
                            <input name="number" id="budget" lay-verify="required|number" autocomplete="off" class="layui-input isNull" type="text">
                          </div>
                        </div>

                        <div class="layui-inline">
                                    <label class="layui-form-label"><a style="color:red">*</a>&nbsp;来源</label>
                                         <div class="layui-input-inline">
                                                 <select name="city" lay-verify="required" lay-search="" class="isNull" id="source">
                                                        <option value="">请选择客户渠道</option>
                                                        <option value="360">360</option>
                                                        <option value="百度">百度</option>
                                                        <option value="大众点评">大众点评</option>
                                                        <option value="上门参观">上门参观</option>
                                                        <option value="异业联盟">异业联盟</option>
                                                        <option value="400主动咨询">400主动咨询</option>
                                                        <option value="老客户转介绍">老客户转介绍</option>
                                                 </select>
                                                 </div>
                                           </div>


                        <div class="layui-inline">
                                   <label class="layui-form-label"><a style="color:red">*</a>&nbsp;销售员</label>
                                              <div class="layui-input-inline">
                                                       <input name="number" id="salesperson" lay-verify="required" autocomplete="off" class="layui-input isNull" type="text">
                                               </div>
                                        </div>
                        <div class="layui-inline">
                                <label class="layui-form-label"><a style="color:red">*</a>&nbsp;微信号</label>
                                         <div class="layui-input-inline">
                                                   <input name="number" id="weixin" lay-verify="required" autocomplete="off" class="layui-input isNull" type="text">
                                         </div>
                         </div>
                         <div class="layui-inline">
                                                          <label class="layui-form-label"><a style="color:red">*</a>&nbsp;是否参观</label>
                                                                  <div class="layui-input-inline">
                                                                       <input name="number" id="visit" lay-verify="required" autocomplete="off" class="layui-input isNull" type="text">
                                                                    </div>
                                                                 </div>
                         <div class="layui-inline">
                                 <label class="layui-form-label"><a style="color:red">*</a>&nbsp;参观次数</label>
                                        <div class="layui-input-inline">
                                                <input name="number" id="visitNumber" lay-verify="required|number" autocomplete="off" class="layui-input isNull isNum" type="text">
                                        </div>
                          </div>
                           <div class="layui-inline">
                                  <label class="layui-form-label"><a style="color:red">*</a>&nbsp;跟进次数</label>
                                      <div class="layui-input-inline">
                                              <input name="number" id="followUp" lay-verify="required|number" autocomplete="off" class="layui-input isNull isNum" type="text">
                                     </div>
                            </div>

                           <div class="layui-inline">
                                 <label class="layui-form-label"><a style="color:red">*</a>&nbsp;建卡地</label>
                                         <div class="layui-input-inline">
                                              <input name="number" id="constructionCard" lay-verify="required" autocomplete="off" class="layui-input isNull" type="text">
                                           </div>
                                        </div>
                       <div class="layui-inline">
			    <label class="layui-form-label"><a style="color:red">*</a>&nbsp;客户等级</label>
                           <div class="layui-input-inline">
			      <select  lay-verify="required" class="isNull" id="lev">
			        <option value="A">A</option>
			        <option value="B">B</option>
			        <option value="C">C</option>
			      </select>
			    </div>
			  </div>
    	      <div class="layui-inline">
                     <label class="layui-form-label" ><a style="color:red">*</a>&nbsp;录入人</label>
                              <div class="layui-input-inline">
                                      <input name="number" id="inputPerson" lay-verify="required" autocomplete="off" class="layui-input isNull" type="text">
                               </div>
              </div>
               <div class="layui-inline">
                                             <label class="layui-form-label">备注</label>
                                                   <div class="layui-input-inline">
                                                         <input name="number" id="remarks" lay-verify="" autocomplete="off" class="layui-input" type="text">
                                                   </div>
                                         </div>
               <div class="layui-inline">
                   <label class="layui-form-label" >客户异议</label>
                       <div class="layui-input-inline">
                             <input name="number" id="objection"   autocomplete="off" class="layui-input" type="text">
                       </div>
               </div>
               <div class="layui-form-item" style="margin-left: 180px">
                       <div class="layui-input-block">
                           <button class="layui-btn layui-btn-radius" lay-submit lay-filter="formDemo" type="button" onclick="onSubmit()" style="background-color: #0092EF;">立即提交</button>
                           <button type="reset" class="layui-btn layui-btn-primary layui-btn-radius">重置</button>
                     </div>
               </div>
            </div>
        </form>

<script>
layui.use(['form', 'layedit', 'laydate','layer'], function(){
  var form = layui.form
  ,layer = layui.layer
  ,layedit = layui.layedit
  ,laydate = layui.laydate;
   //日期
  laydate.render({
    elem: '#date'
  });

});
//添加
function onSubmit(){


//验证手机号
if(!isPhone()){
return;
}

if(!isNum()){
return;
}

 if(!isNull()){
        return;
       }








var jsonData = {};
    jsonData.name = $("#name").val();
    jsonData.phone = $("#phone").val();
    jsonData.expected = $("#date").val();
    jsonData.address = $("#address").val();
    jsonData.competitor = $("#competitor").val();
    jsonData.budget = $("#budget").val();
    jsonData.constructionCard = $("#constructionCard").val();
    jsonData.lev = $("#lev").val();
    jsonData.inputPerson = $("#inputPerson").val();
    jsonData.objection = $("#objection").val();
    //客户来源
    jsonData.source = $("#source").val();
    //是否参观
    jsonData.visit = $("#visit").val();
    //销售员
    jsonData.salesperson = $("#salesperson").val();
    //微信号
    jsonData.weixin = $("#weixin").val();
    //参观次数
    jsonData.visitNumber = $("#visitNumber").val();
    //跟进次数
    jsonData.followUp = $("#followUp").val();
    //备注
    jsonData.remarks = $("#remarks").val();

        //alert("进入ajax")
     $.ajax({
        type:"POST",
        url:"${base}/customer/insertCustomer",
        data:{"param":JSON.stringify(jsonData)},
        success:function(data){

             layer.msg(data);
setTimeout(function(){
   var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
          parent.layer.close(index); //再执行关闭
},200)
             //清空表格
             var name = $("#name").val("");
             var name = $("#phone").val("");
             var date = $("#date").val("");
             var address = $("#address").val("");
             var competitor = $("#competitor").val("");
             var budget = $("#budget").val("");
             var constructionCard = $("#constructionCard").val("");
             var lev = $("#lev").val("");
             var inputPerson = $("#inputPerson").val("");
             var objection = $("#objection").val("");
             //客户来源
                 jsonData.source = $("#source").val("");
                 //是否参观
                 jsonData.visit = $("#visit").val("");
                 //销售员
                 jsonData.salesperson = $("#salesperson").val("");
                 //微信号
                 jsonData.weixin = $("#weixin").val("");
                 //参观次数
                 jsonData.visitNumber = $("#visitNumber").val("");
                 //跟进次数
                 jsonData.followUp = $("#followUp").val("");
                 //备注
                 jsonData.remarks = $("#remarks").val("");
             var table = parent.layui.table;
                //表刷新方法
                table.reload('testReload', {
                url: '${base}/customer/selectCustomer'
                ,where: {} //设定异步数据接口的额外参数

            });
        }
     });

}

//键盘事件
   $("body").bind("keydown",function(e){
       // 兼容FF和IE和Opera
       var theEvent = e || window.event;
       var code = theEvent.keyCode || theEvent.which || theEvent.charCode;
       if (code == 13) {
           //回车执行查询
           $("#btn1").click();
       }
   });
</script>
	</body>
</html>
